﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ExampleDLL;
using ExampleDLL.Entities;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Call the random Number method - min and max values
            int returnValue = Utility.RandomNumber(5, 20);
            label1.Text = Convert.ToString(returnValue);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (Utility.NumberRangeValidator(1, 10, textBox1.Text))
                textBox1.Text = "not valid";
        }

        private void button3_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            if (!Utility.NumberRangeValidator(1000, 2000, textBox2.Text))
            {
                //Entity Object
                Missile mis = new Missile();
                mis.Speed = Convert.ToInt16(textBox2.Text);
                //Pass Missile object to the DLL for writing
                if (XMLHandler.WriteXML(mis))
                    MessageBox.Show("Missile XML File created");
                else
                    MessageBox.Show("Missile XML NOT File created");
            }
        }
    }
}
